#!/bin/bash
rpm -q mailx &>/dev/null
if [ $? -ne 0 ]; then
        yum install mailx -y
fi
while true; do
        num=$(ss -tl | grep -c mysql)
        if [ $num -eq 0 ]; then
                echo "赶快重启mysql的服务" | mail -s "mysql已经关闭" 1024335892@qq.com
                break
        fi
done
